<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>单页列表</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<!--公共JS开始-->
<script src="__PUBLIC__/Js/jquery.min.js"></script>
<script src="__PUBLIC__/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<!--公共JS结束-->
<!--数据列表插件开始-->
<link href="__PUBLIC__/Plugins/ContextMenu/src/jquery.contextMenu.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/Plugins/Etgrid/Css/etgrid.css" rel="stylesheet" type="text/css">
<script src="__PUBLIC__/Plugins/ContextMenu/src/jquery.ui.position.js"></script>
<script src="__PUBLIC__/Plugins/ContextMenu/src/jquery.contextMenu.js"></script>
<script src="__PUBLIC__/Plugins/Etgrid/Js/etgrid.js"></script>
<!--数据列表插件结束-->
<style type="text/css">
	body {
		overflow:hidden;
	}
	.table_box {
	}
</style>
</head>

<body>
<div class="page_header">
	<div class="table_tool">
		<ul class="clearfix">			
			<li class="openwin btn" etitle="添加单页" eheight="500px" id="Content_artonceAdd"
				ewidth="800px" ehref="{:U('Content/artonceAdd')}" >
				<i class="icon-plus"></i> 添加单页
			</li>
			<li class="moreDel btn"><i class="icon-remove"></i> 批量删除</li>
			<li class="moreChecked btn" class="moreDel">
				<i class="icon-asterisk"></i> 批量审核
				<ul class="submenu">
					<li toid="added" value="1"><i class="icon-caret-right"></i> 通过审核</li>
					<li toid="offed" value="2"><i class="icon-caret-right"></i> 取消审核</li>
				</ul>
			</li>
		</ul>
	</div>
	
	<div class="search_box">
		<form name="searchForm" id="searchForm" action="#" >
		{$arg_site|listSiteShow=###}<!--多站点支持-->
		{$arg_lang|listLangShow=###}<!--多语言支持-->
		{$arg_cateid|listCateidShow=###}<!--所属栏目支持-->
		
		<select name="checked" id="checked" class="form_ele">
			<option value="">审核状态</option>
			<option value="1">通过</option>
			<option value="2">未通过</option>
		</select>
		
		{$arg_isdel|listIsdelShow=###}<!--查看支持-->
		
		<input type="text" id="keywords" class="form_ele w300" placeholder="请输入标题搜索"/>
		<span id="doSearch" class="doSearch">
			<i class="icon-search"></i> 搜索
		</span>
		<span id="doReset" class="doSearch clearSearch">重置搜索条件</span>
		</form>
	</div>
</div>
	<div class="table_box">
	</div>
</body>
<script type="text/javascript">
$(function(){

	//批量审核
	$('.moreChecked>ul>li').on('click',function(){
		var val = tableList.getChecked();
		var checked     = $(this).attr('value');
 		var msg = "确认要将选中的单页全部审核吗？";
		
		if(val){
			windowApi.lhgdialog.confirm(msg, function(){
				$.post("{:U('Content/artonceChecked')}",{id:val,checked:checked},function(data){
					if(data.status==1){
						$('.et_tfoot .page_refresh').click(); //刷新加载
					}else{
						windowApi.lhgdialog.alert(data.info,function(){return;});
					}
				});
			},function(){
				return;
			});
		}else{
			windowApi.lhgdialog.alert('请选择要审核的单页！');
		}
	});

	//批量删除
	$('.moreDel').on('click',function(){
		var val = tableList.getChecked();
		
 		var msg = "确认要将选中的单页全部删除吗？";
		
		if(val){
			windowApi.lhgdialog.confirm(msg, function(){
				$.post("{:U('Content/artonceMoreDel')}",{id:val},function(data){
					if(data.status==1){
						$('.et_tfoot .page_refresh').click(); //刷新加载
					}else{
						windowApi.lhgdialog.alert(data.info,function(){return;});
					}
				});
			},function(){
				return;
			});
		}else{
			windowApi.lhgdialog.alert('请选择要删除的单页！');
		}
	});
	
	//搜索
	$('#doSearch').on('click',function(){
		
		var where = tableList.config.getWhere();
		var key   = $('#keywords').val();
		if(key){
			where.title = ['like','%'+key+'%'];
		}
		tableList.config.where = where;
		tableList.search();
	});
	
	//重置
	$('#doReset').on('click',function(){
		document.forms['searchForm'].reset();
	});
});


//弹出窗口全局变量
var api = frameElement.api, W = api.opener;

	var listConfig = {
			blockBox : '.table_box',
			blockBoxHeight : 'window',
			jsonUrl : '__URL__/artonce',
			where : '',
			getWhere : function(){
				var where   = {};
				where.checked = $('#checked').val();
				where.isdel   = $('#isdel').val();
				where.lang    = $('#lang').val();
				where.cateid  = $('#cateid').val();
				
				return where;
			},
			showPageNav: true,
			widthType : 'tdw', //thw-标题标准宽度、tdw-数据单元标准宽度、auto-随数据单元宽度
			pageNum : 10,
			nowPage : 1,
			orderName : "sort",
			orderDirection : "desc",
			dataContextMenuOpen: true, //是否开启数据行右键菜单
			showPageNav: true,
			dataContextMenu: function(){
				$.contextMenu({
					selector: '.et_tbody tr',
					items: {
						"edit": {
							name: "修改", 
							icon: "edit",
							callback: function(key, options) {
								var href   = '__URL__/artonceEdit/id/'+$(this).attr('rowid');
								var width  = '960px';
								var height = '500px';
								var title  = '修改单页';
								openDialog('Content_artonceEdit',href,width,height,title);
							}
						},
						"delete": {
							name: "删除", 
							icon: "edit",
							callback: function(key, options) {
								
								var val = $(this).attr('rowid');
						 		var msg = "确认要将删除单页吗？";
						 		
								windowApi.lhgdialog.confirm(msg, function(){
									$.get("{:U('Content/artonceDel')}",{id:val},function(data){
										if(data.status==1){
											$('.et_tfoot .page_refresh').click(); //刷新加载
										}else{
											windowApi.lhgdialog.alert(data.info,function(){return;});
										}
									});
								},function(){
									return;
								});
							}
						},
						
					}
				});
			},
			colModel : [
				{
					display : 'checkbox',
					name : 'id',
					sortable : false,
					myclass : 'center',
					edit : false,
					width : '20px'
				},
				{
					display : '标题',
					name : 'title',
					sortable : true,
					myclass : 'center',
					edit : true
				},
				{
					display : '排序号',
					name : 'sort',
					sortable : true,
					myclass : 'center',
					edit : false,
					width : '100px'
				},
				{
					display : '添加时间',
					name : 'addtime',
					sortable : true,
					myclass : 'center',
					edit : false
				},
				{
					display : '审核',
					name : 'checked',
					sortable : false,
					myclass : 'center',
					edit : false,
					width : '50px'
				}
			]
		};
	
	//实例化列表
	var tableList = $('.table_box').EtGrid(listConfig);
	//tableList.erefresh();
</script>
</html>
